package com.sjms._01_创建_单例;

//形式1-静态常量-new
class A {
    private static final A a = new A();

    public A() {
    }

    public static A getInstance() {
        return a;
    }
}

//形式2-静态常量-静态代码块
class B {
    private static final B b;

    private B() {

    }

    static {
        b = new B();
    }

    public static B getInstance() {
        return b;
    }
}
//形式1-静态常量-new
//形式2-静态常量-静态代码块
public class Test1 {
    public static void main(String[] args) {
        System.out.println(A.getInstance());
        System.out.println(B.getInstance());
    }
}
